<html>
<head><meta charset="utf-8"><title>Name Resolution · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html">Name Resolution</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="163038361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/163038361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#163038361">(Apr 10 2019 at 19:38)</a>:</h4>
<p>Skimming the meeting notes from weekly meeting 2019-04-04 <a href="https://github.com/rust-lang/rust/issues/54818" target="_blank" title="https://github.com/rust-lang/rust/issues/54818">#54818</a> I saw this:</p>
<blockquote>
<p>The actual name resolution is waiting for <span class="user-mention silent" data-user-id="116083">pnkfelix</span> and <span class="user-mention silent" data-user-id="116009">nikomatsakis</span> though: hopefully we create a plan of attack next week?</p>
</blockquote>
<p>hey <span class="user-mention" data-user-id="133169">@matklad</span> and <span class="user-mention" data-user-id="116083">@pnkfelix</span> -- say more about this? =)</p>



<a name="163041158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/163041158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#163041158">(Apr 10 2019 at 20:12)</a>:</h4>
<p>We need to plan nameresolution librarification basically. Currently at least I don’t have any clear idea of how it should look like. This week turned out pretty busy for me,though :(</p>



<a name="163042945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/163042945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#163042945">(Apr 10 2019 at 20:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="116083">@pnkfelix</span> any change that tomorrow might work for you (<a href="https://doodle.com/poll/dps6yqmwmzpwr2x6" target="_blank" title="https://doodle.com/poll/dps6yqmwmzpwr2x6">https://doodle.com/poll/dps6yqmwmzpwr2x6</a>)? </p>
<p>I feel like we should get this going already :)</p>



<a name="163050744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/163050744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#163050744">(Apr 10 2019 at 22:07)</a>:</h4>
<p>I filled that in with my availability</p>



<a name="163077321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/163077321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#163077321">(Apr 11 2019 at 07:38)</a>:</h4>
<p>looks like there's no time that fits everyone :(</p>



<a name="163103727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/163103727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#163103727">(Apr 11 2019 at 14:20)</a>:</h4>
<p>I'm happy to be excluded</p>



<a name="163103729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/163103729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#163103729">(Apr 11 2019 at 14:20)</a>:</h4>
<p>:)</p>



<a name="219385968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219385968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219385968">(Dec 09 2020 at 19:30)</a>:</h4>
<p>Can you resolve a crate independent of its dependencies?</p>



<a name="219386168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386168">(Dec 09 2020 at 19:31)</a>:</h4>
<p>no, because it can refer to dependent crates</p>



<a name="219386176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386176">(Dec 09 2020 at 19:31)</a>:</h4>
<p>I’m still learning so I will attempt to answer my own question and if possible please correct my erroneous thinking.</p>
<p>use foo::bar</p>
<p>let x = bar.get()</p>
<p>If resolution stores the ‘bar’ symbol without knowing whether it is a method or not, we can resolve the above</p>



<a name="219386179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386179">(Dec 09 2020 at 19:32)</a>:</h4>
<p>like <code>use serde::Deserialize</code></p>



<a name="219386264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386264">(Dec 09 2020 at 19:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="364259">Joe Seriah</span> <a href="#narrow/stream/131828-t-compiler/topic/Name.20Resolution/near/219386176">said</a>:</p>
<blockquote>
<p>I’m still learning so I will attempt to answer my own question and if possible please correct my erroneous thinking.</p>
<p>use foo::bar</p>
<p>let x = bar.get()</p>
<p>If resolution stores the ‘bar’ symbol without knowing whether it is a method or not, we can resolve the above</p>
</blockquote>
<p>there are different namespaces, so that doesn't work</p>



<a name="219386275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386275">(Dec 09 2020 at 19:32)</a>:</h4>
<p>you need to know which namespace the item is in to know if the name overlaps</p>



<a name="219386404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386404">(Dec 09 2020 at 19:33)</a>:</h4>
<p>Can you give an example of overlapping?</p>



<a name="219386639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386639">(Dec 09 2020 at 19:34)</a>:</h4>
<p>My thinking is that to resolve you just need to know that the expression was made from previously declared symbols?</p>



<a name="219386697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386697">(Dec 09 2020 at 19:34)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">S</span><span class="p">;</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">S</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="n">macro_rules</span><span class="o">!</span><span class="w"> </span><span class="n">S</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="219386816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386816">(Dec 09 2020 at 19:36)</a>:</h4>
<p>Hmm there are no use statements here?</p>



<a name="219386882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386882">(Dec 09 2020 at 19:36)</a>:</h4>
<p>right, yes, but they are all in the same module</p>



<a name="219386897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386897">(Dec 09 2020 at 19:36)</a>:</h4>
<p>you don't know what <code>module::S</code> refers to</p>



<a name="219386983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219386983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219386983">(Dec 09 2020 at 19:37)</a>:</h4>
<p>Oh right, yeah on the same page, so my thought was that you don’t need to know, in order to name resolve another crate</p>



<a name="219387025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219387025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219387025">(Dec 09 2020 at 19:37)</a>:</h4>
<p>use foo::S</p>
<p>let x = S</p>



<a name="219387055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219387055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219387055">(Dec 09 2020 at 19:37)</a>:</h4>
<p>This would pass because S is from the foo crate, whatever item it is</p>



<a name="219387073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219387073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219387073">(Dec 09 2020 at 19:37)</a>:</h4>
<p>To nit: <code>fn S()</code> and <code>struct S</code> will actually overlap (and conflict) on the value namespace (<code>struct S;</code> is <code>struct S {}</code> <em>and</em> <code>const S: S = S {};</code>)</p>



<a name="219387182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219387182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219387182">(Dec 09 2020 at 19:38)</a>:</h4>
<p>oh thanks, yeah I meant <code>struct S {}</code></p>



<a name="219387329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219387329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219387329">(Dec 09 2020 at 19:39)</a>:</h4>
<p>(Full details for Daniel's point: <a href="https://rust-lang.github.io/rfcs/1506-adt-kinds.html#tuple-structs">https://rust-lang.github.io/rfcs/1506-adt-kinds.html#tuple-structs</a>)</p>



<a name="219387561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219387561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219387561">(Dec 09 2020 at 19:40)</a>:</h4>
<p>use foo::bar</p>
<p>let j = bar::hello2::call()</p>
<p>So this would pass too for example, there might not be a hello2 module that exists. But for name resolution I think thats fine? As long as Mamés are resolved to something</p>



<a name="219387859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219387859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219387859">(Dec 09 2020 at 19:43)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> I ask because it seems that rustc is doing something similar. Macros and imports seem to not be resolved immediately from a doc comment I read</p>



<a name="219388036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219388036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219388036">(Dec 09 2020 at 19:44)</a>:</h4>
<p>———————<br>
Still wondering if I am understanding what is happening correctly though?</p>



<a name="219388442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219388442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219388442">(Dec 09 2020 at 19:47)</a>:</h4>
<p>macro expansion happens interleaved with name resolution (because macro expansion can create new names), and you obviously need the dependency crates to expand macros from them</p>



<a name="219388738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219388738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219388738">(Dec 09 2020 at 19:50)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> oh I see, can you explain what happens during late resolution?</p>



<a name="219388804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219388804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219388804">(Dec 09 2020 at 19:51)</a>:</h4>
<p><span class="user-mention" data-user-id="364259">@Joe Seriah</span> have you read through the guide? <a href="https://rustc-dev-guide.rust-lang.org/name-resolution.html?highlight=resolve#name-resolution">https://rustc-dev-guide.rust-lang.org/name-resolution.html?highlight=resolve#name-resolution</a></p>



<a name="219390062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219390062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219390062">(Dec 09 2020 at 20:02)</a>:</h4>
<p>Yep, I just re-read it and corrected myself as it says the macros are already expanded. It does say that imports are resolved, it’s still a bit unclear as to why you need to resolve imports to me though</p>



<a name="219390163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219390163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219390163">(Dec 09 2020 at 20:02)</a>:</h4>
<p>I also saw this which made me think that imports are not fully resolved: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_hir/def.rs.html#247">https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_hir/def.rs.html#247</a></p>



<a name="219390237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219390237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219390237">(Dec 09 2020 at 20:03)</a>:</h4>
<p>Or at least not fully</p>



<a name="219391028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391028">(Dec 09 2020 at 20:10)</a>:</h4>
<p>A path may be partially resolved if some of the contained items are produced by macros</p>



<a name="219391544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391544">(Dec 09 2020 at 20:15)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span>  That makes sense. My last confusion is, if we don’t use macros, then during name resolution, why do we need to resolve the path?</p>
<p>Maybe there’s a reason the following cannot/should not be resolved without resolving imports first? </p>
<p>use baz::foo;</p>
<p>Let bar = foo;<br>
Let x = foo + bar;</p>



<a name="219391639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391639">(Dec 09 2020 at 20:16)</a>:</h4>
<p>How would you know what <code>foo</code> means without some amount of path resolution?</p>



<a name="219391645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391645">(Dec 09 2020 at 20:16)</a>:</h4>
<p>Assuming no macros this time; trying to get an understanding</p>



<a name="219391688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391688">(Dec 09 2020 at 20:16)</a>:</h4>
<p>We only need to know that foo resolved to a symbol?</p>



<a name="219391705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391705">(Dec 09 2020 at 20:16)</a>:</h4>
<p>Sorry, that foo is a symbol</p>



<a name="219391709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391709">(Dec 09 2020 at 20:16)</a>:</h4>
<p>that's not what name resolution does though</p>



<a name="219391722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391722">(Dec 09 2020 at 20:17)</a>:</h4>
<p>it resolves to a DefId, not to a symbol</p>



<a name="219391738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391738">(Dec 09 2020 at 20:17)</a>:</h4>
<p>The compiler needs to know which item <code>foo</code> resolves to so it can typecheck</p>



<a name="219391764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391764">(Dec 09 2020 at 20:17)</a>:</h4>
<p>(well, technically a <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def/enum.Res.html"><code>Res</code></a>)</p>



<a name="219391765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391765">(Dec 09 2020 at 20:17)</a>:</h4>
<p>Oh, why do we need to type check in the name resolution?</p>



<a name="219391778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391778">(Dec 09 2020 at 20:17)</a>:</h4>
<p>no no other way</p>



<a name="219391785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391785">(Dec 09 2020 at 20:17)</a>:</h4>
<p>type checking needs name resolution</p>



<a name="219391798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391798">(Dec 09 2020 at 20:17)</a>:</h4>
<p>otherwise it doesn't have any information to work with</p>



<a name="219391896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391896">(Dec 09 2020 at 20:18)</a>:</h4>
<p>For example, how would you know what code to generate for this <code>main</code> function if you don't know what <code>foo</code> resolves to?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">use</span><span class="w"> </span><span class="n">bar</span>::<span class="n">foo</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="219391901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391901">(Dec 09 2020 at 20:18)</a>:</h4>
<p>So it would not be possible to resolve it as a symbol first and then resolve the import path in a path resolution phase?</p>



<a name="219391951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391951">(Dec 09 2020 at 20:19)</a>:</h4>
<p>Rust has no concept of symbols</p>



<a name="219391954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391954">(Dec 09 2020 at 20:19)</a>:</h4>
<p>what does 'resolve it as a symbol' mean?</p>



<a name="219391967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219391967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219391967">(Dec 09 2020 at 20:19)</a>:</h4>
<p>At least not of symbols like that</p>



<a name="219392008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392008">(Dec 09 2020 at 20:19)</a>:</h4>
<p>What exactly do you mean by "symbol" here?</p>



<a name="219392088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392088">(Dec 09 2020 at 20:20)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> the example you made would pass name resolution, but it may not pass path resolution if there is no function foo under the path</p>



<a name="219392141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392141">(Dec 09 2020 at 20:20)</a>:</h4>
<p>you've made up your own vocabulary without explaining it</p>



<a name="219392159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392159">(Dec 09 2020 at 20:20)</a>:</h4>
<p>what is a symbol? what are the outputs from 'name resolution'?</p>



<a name="219392344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392344">(Dec 09 2020 at 20:22)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> good point, by symbol I mean it’s a string which identifies a node</p>



<a name="219392392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392392">(Dec 09 2020 at 20:22)</a>:</h4>
<p>Well, we have several structures that can identify nodes, like <code>NodeId</code> and <code>DefId</code></p>



<a name="219392419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392419">(Dec 09 2020 at 20:22)</a>:</h4>
<p>Why use a string, specifically?</p>



<a name="219392661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392661">(Dec 09 2020 at 20:25)</a>:</h4>
<p>I mentioned string specifically because for example in;</p>
<p>use bar::foo</p>
<p>let x = 1 + foo</p>
<p>We would store foo as a String, and then when we see the add expr we just lookup the ‘foo’ mentioned in the expression with the foo from the import we stored</p>



<a name="219392713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392713">(Dec 09 2020 at 20:25)</a>:</h4>
<p>that's not actually doing any work though? that says take "foo" as a string and output "foo" as a string</p>



<a name="219392814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392814">(Dec 09 2020 at 20:26)</a>:</h4>
<p>I think it looks up foo in the expression to see if we have foo in a map?</p>



<a name="219392840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392840">(Dec 09 2020 at 20:26)</a>:</h4>
<p>but you can't without resolving imports :/</p>



<a name="219392859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392859">(Dec 09 2020 at 20:26)</a>:</h4>
<p>like glob imports are completely unknown if you dont' compile dependencies</p>



<a name="219392908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219392908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219392908">(Dec 09 2020 at 20:26)</a>:</h4>
<p>also this breaks shadowing, now you need to do that later too</p>



<a name="219393081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219393081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219393081">(Dec 09 2020 at 20:28)</a>:</h4>
<p>It might be worthwhile to look at rust-analyzer's code instead of rustc's, since rust-analyzer's code tends to be more readable and do more fine-grained work to improve incremental computation</p>



<a name="219393216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Name%20Resolution/near/219393216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Seriah <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Name.20Resolution.html#219393216">(Dec 09 2020 at 20:29)</a>:</h4>
<p>Alright will do, thank you again for the help and discussion</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>